{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<div class="t-a-wait-con">
    <div class="tablesWrap">
        <div class="tables-searchbox">
            <div class="t-a-wait-top">
                <form action="" method="post" id="rank_waiting">
                    <div class="t-a-wait-top-li" style="width:400px;">
                        <div class="formitems inline">
                            <label class="fi-name" style="width:70px; font-weight:normal;">活动时间：</label>
                            <div class="form-controls" style="margin-left:80px;">
                                <input type="text" style="width:120px;" autocomplete="off" class="Wdate" name="start_time" value="{if $start_time}{date('Y-m-d',$start_time)}{/if}" onclick="WdatePicker({ dateFmt:'yyyy-MM-dd'})">

                                <span class="fi-text">-</span>

                                <input type="text" style="width:120px;" autocomplete="off" class="Wdate" name="end_time" value="{if $end_time}{date('Y-m-d',$end_time)}{/if}" onclick="WdatePicker({ dateFmt:'yyyy-MM-dd'})">
                            </div>
                        </div>
                    </div>

                    <div class="t-a-wait-top-li" style=""><input type="hidden" name="submit" value="search" /><button class="btn"><i class="gicon-search"></i>搜索</button> </div>
                </form>
            </div>
        </div>
        <table class="wxtables">
            <colgroup>
                <col width="10%">
                <col width="10%">
                <col width="10%">
                <col width="10%">
                <col width="10%">
            </colgroup>
            <thead>
                <tr>
                    <!--<td>选择</td>-->
                    <td>活动名称</td>
                    <td>订单金额</td>
                    <td>减免额度</td>
                    <td>活动时间</td>
                    <td>操作</td>
                </tr>
            </thead>
            {foreach from=$discount_list item=discount_item}
            <tbody class="combo-tbody">
            <tr>
                <!-- <td><input type="checkbox" class="checkbox" value='{$discount_item.discount_minus_id}' name="a[]"></td> -->
                <td>{$discount_item.title}</td>
                <td>{$discount_item.amount_limit}</td>
                <td>{$discount_item.num}</td>
                <td>{$discount_item.start_time|date_format:"%Y-%m-%d %H:%M:%S"} -- {$discount_item.end_time|date_format:"%Y-%m-%d %H:%M:%S"}</td>
                <td>
                    <a href="/AcpDiscountMinus/edit_discount_minus/discount_minus_id/{$discount_item.discount_minus_id}" class="btn" title="修改">修改</a>
                    <a href="/AcpDiscountMinus/get_discount_minus_detail/discount_id/{$discount_item.discount_minus_id}" class="btn" title="查看活动明细">查看活动明细</a>
                </td>
            </tr>
            </tbody>
            {foreachelse}
            <tbody>
            <tr>
                <td colspan="7">
                    没有符合条件的记录
                </td>
                <tr>
                    </tbody>
                    {/foreach}
                </table>
                <!-- end wxtables -->
                <div class="tables-btmctrl clearfix">
                <!--
                    <div class="fl">
                        <a href="javascript:;" class="btn btn-blue" onclick="Select()">全选</a>
                        <a href="javascript:;" class="btn btn-blue" onclick="Cancel()">取消</a>
                    </div>
                    -->
                    <a href="javascript:;" onclick='discount_link()' class="btn btn-blue" title="复制活动链接">复制活动链接</a>
                    <div class="fr">
                        <div class="paginate">
                            {$show}
                        </div>
                        <!-- end paginate -->
                    </div>
                </div>
                <!-- end tables-btmctrl -->
            </div>
            <!-- end tablesWrap -->
        </div>
        {/block}

        {block name="js"}
        <script src="/Public/Plugins/My97DatePicker/WdatePicker.js?version={$version}"></script>
        {literal}
        <script>
//全选
        function Select(){
            var sel=document.getElementsByName("a[]");
            for(var i=0;i<sel.length;i++){
                sel[i].checked=true;
            }
        }
//取消全选
function Cancel(){
    var sel=document.getElementsByName("a[]");
    for(var i=0;i<sel.length;i++){
        sel[i].checked=false;
    }
}

function set_is_enable(id, is_enable)
{
    opt = (is_enable == 1) ? '激活' : '禁用';
    $.jPops.confirm(
            {
    title:"提示",
    content:"您确定要执行该操作吗？",
    okBtnTxt:"确定",
    cancelBtnTxt:"取消",
    callback:function(r)
    {
    if(r)
    {
    $.post('/AcpUserAjax/set_user_is_enable', {"user_id":id, "is_enable":is_enable}, function(data, textStatus)
        {
        if (data == 'success')
        {
        alert('恭喜您，' + opt + '成功！');
        location.reload();
        }
        else
        {
        alert('对不起，' + opt + '失败');
        }
        });
    }
    return true;
    }
    });
}

function batch_set_is_enable(is_enable)
{
    opt = (is_enable == 1) ? '激活' : '禁用';
    $.jPops.confirm({
        title:"提示",
        content:"您确定要执行这些操作吗？",
        okBtnTxt:"确定",
        cancelBtnTxt:"取消",
        callback:function(r)
        {
            if(r)
            {
            var ids = '';
            var count = 0;
            $('input[name="a[]"]:checked').each(function(){
                count ++;
                ids += $(this).val() + ',';
                });

            if (!count)
            {
            alert('对不起，请选择至少一项进行操作！');
            return;
            }

            ids = ids.substr(0, ids.length - 1);

            $.post('/AcpUserAjax/batch_set_user_is_enable', {"user_ids":ids, "is_enable":is_enable}, function(data, textStatus)
                    {
                    if (data == 'success')
                    {
                    alert('恭喜您，' + opt + '成功！');
                    location.reload();
                    }
                    else
                    {
                    alert('对不起，' + opt + '失败');
                    }
                    });
            }
        return true;
        }
        });
}

//复制商品链接
function discount_link()
{
    var link = 'http://' + document.domain + '/FrontCoupon/full_minus_list/';
    $.jPops.custom({
        title:"请复制链接",  
        content:'<div>活动链接：' + link + '</div>',
        okBtnTxt:"复制",  
        cancelBtnTxt:"关闭",  
        callback:function(r)
        {
            if(r)
            {
                text = link;
                copy_text('jpops-btn-ok');
            }
            else
            {
                return true;  
            }
        }
    });
}
function copy_text(id)
    {
        var clipboard = new Clipboard('#' + id, {
            text: function() {
                return text;
            }
        });

        clipboard.on('success', function(e) {
            console.log(e);
            alert('复制成功');
        });

        clipboard.on('error', function(e) {
            console.log(e);
            alert('复制失败，请手动复制');
        });
    } 
        </script>
        {/literal}
        {/block}

        {block name="css"}
        <link rel="stylesheet" href="/Public/Css/acp/AcpUser/audit_waiting.css" type="text/css" />
        {/block}
